var t = getApp();

Page({
    data: {
        active: 0,
        status_list: [ "全部", "未结算", "已结算", "已失效" ],
        current_index: 0,
        info: {},
        language: "",
        list: [],
        amounts_list: [],
        page: 1,
        total_page: 1
    },
    onLoad: function(t) {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        }), this.get_rewards();
    },
    get_rewards: function() {
        var a = this, e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1, s = {
            page: e,
            status: this.data.current_index
        };
        0 == this.data.current_index && (s.status = 4), t._postNetWork({
            url: t.getNetAddresss("plugin.distributor-team.frontend.controllers.rewards.index"),
            data: s,
            success: function(s) {
                var n = s.data, i = n.result, o = n.msg, r = n.data;
                if (i) {
                    var d = r.info, u = r.list;
                    a.data.page = u.current_page, a.data.total_page = u.last_page, 1 == e ? a.setData({
                        list: u.data,
                        info: d
                    }) : a.setData({
                        list: a.data.list.concat(u.data)
                    });
                } else t.tips(o);
            }
        });
    },
    get_amounts: function() {
        var a = this, e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : 1;
        t._postNetWork({
            url: t.getNetAddresss("plugin.distributor-team.frontend.controllers.amounts.index"),
            data: {
                page: e
            },
            success: function(s) {
                var n = s.data, i = n.result, o = n.msg, r = n.data;
                if (i) {
                    var d = r.info, u = r.list;
                    a.data.page = u.current_page, a.data.total_page = u.last_page, 1 == e ? a.setData({
                        amounts_list: u.data,
                        info: d
                    }) : a.setData({
                        amounts_list: a.data.amounts_list.concat(u.data)
                    });
                } else t.tips(o);
            }
        });
    },
    getMoreData: function() {
        if (!(this.data.page >= this.data.total_page)) {
            var t = this.data.page + 1;
            0 == this.data.active ? this.get_rewards(t) : this.get_amounts(t);
        }
    },
    toggle: function(t) {
        this.setData({
            current_index: t.currentTarget.dataset.i
        }), this.get_rewards();
    },
    onClick: function(t) {
        this.setData({
            active: t.detail.index
        }), 0 == t.detail.index ? this.get_rewards() : this.get_amounts();
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.getMoreData();
    },
    onShareAppMessage: function() {}
});